package com.yigang.controller;

import java.text.ParseException;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yigang.entity.Orderdetails;
import com.yigang.service.OrderdetailsService;
import com.yigang.utils.ResultUtil;
/**
 * @author 陈佳祥
 *订单详情管理
 */
@Controller
@RequestMapping("/orderdetails")
public class OrderdetailsController {
	@Autowired
		private OrderdetailsService orderdetailsService;
	//椤甸潰閲嶅畾鍚�
		@RequestMapping("orderdetailsList")
		public String orderdetailsList() {
			return "jsp/orderdetails/orderdetailsList";
		}
		@RequestMapping("addOrderdetails")
		public String addOrderdetails() {
			return "jsp/orderdetails/addOrderdetails";
		}
		
		@RequestMapping("editOrderdetails/{orderdetails_id}")
		public String editOrderdetails(@PathVariable("orderdetails_id") int orderdetails_id, HttpSession session) {
			Orderdetails orderdetails = orderdetailsService.selectOrderdetailsById(orderdetails_id);
		
			session.setAttribute("orderdetails", orderdetails);
			return "jsp/orderdetails/editOrderdetails";
		}
		
		//澧炲垹鏌ユ敼鏂规硶
		@RequestMapping("insertOrderdetails")
		@ResponseBody
		public ResultUtil insertOrderdetails(Orderdetails record) {
			orderdetailsService.insertSelective(record);
			return ResultUtil.ok();

		}

		@RequestMapping("deleteOrderdetailsById")
		@ResponseBody
		public ResultUtil deleteOrderdetailsById(int orderdetails_id) {
			
			return orderdetailsService.deleteByPrimaryKey(orderdetails_id);
		}

		@RequestMapping("getOrderdetailsList")
		@ResponseBody
		public ResultUtil getOrderdetailsList(Integer page, Integer limit, Orderdetails record) {

			return orderdetailsService.selectOrderdetailsList(page, limit, record);
		}

		@RequestMapping("updateOrderdetails")
		@ResponseBody
		public ResultUtil updateOrderdetails(Orderdetails record) throws ParseException {
			
			return orderdetailsService.updateByPrimaryKeySelective(record);
		}
}
